import datetime
import os
import pathlib
import re



def return_dijizhou(datetime):   #上周是第几周
     dijizhou=datetime.isocalendar()[1]
     return  dijizhou
# 使用方法 dijizhou=return_dijizhou(datetime.datetime.now())

def file_exit(datetime):#文件名称是第几周.xls
    dijizhou=datetime.isocalendar()[1]
    filename=str(dijizhou)+'.xls'
    path='C:/Users/Administrator/Desktop/'
    file=pathlib.Path(path+filename)
    print(file)
    if file.is_file():
        return True
    else:
        return False

def shengsanfang_tousu(path): # 省三方投诉
    os.chdir(r"C:\Users\Administrator")   #切换到桌面目录
    file=open(path,encoding="utf-8")
    content=file.read()
    result = re.findall('<td>省第三方链路</td><td>?([\u4e00-\u9fa5]*)</td>', content, re.S)
    print(result)
    file.close()


def sidazhuanxiang(path):  # 省三方投诉
    os.chdir(r"C:\Users\Administrator")  # 切换到桌面目录
    file = open(path, encoding="utf-8")
    content = file.read()
    result1 = re.findall('<td>网页类</td>', content, re.S)
    result2 = re.findall('<td>游戏类</td>', content, re.S)
    result3 = re.findall('<td>企业专线</td>', content, re.S)
    print('网页类数量：%d'%(len(result1))+'\n')
    print('游戏数量：%d'%(len(result2)) + '\n')
    print('政企类数量：%d'%(len(result3)) + '\n')
    file.close()




shengsanfang_tousu('27.txt')






